package anthology.daily_question._25_01;
//https://leetcode.cn/problems/largest-3-same-digit-number-in-string/description/?envType=daily-question&envId=2025-01-08
public class _2264字符串中最大的3位相同数字 {
    class Solution {
        public String largestGoodInteger(String num) {
            String[] strings = {"999","888","777","666","555","444","333","222","111","000"};
            for(String s : strings){
                if(num.contains(s)){
                    return s;
                }
            }
            return "";
        }
    }
    class Solution2 {
        public String largestGoodInteger(String num) {
            for (char d = '9'; d >= '0'; d--) {
                String s = String.valueOf(d).repeat(3);
                if (num.contains(s)) {
                    return s;
                }
            }
            return "";
        }
    }
}
